<%@ page import="mybatis.pojo.Subject" %>
<%@ page import="mybatis.services.SubjectService" %>
<%@ page import="mybatis.pojo.Admin" %>
<%@ page import="mybatis.services.AdminService" %><%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2022/7/4
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%

    request.setCharacterEncoding("utf-8");
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    Admin admin = new Admin();
    admin.setUsername(username);
    admin.setPassword(password);
    int r= AdminService.ME.add(admin);
    if(r>0){
        //表单重复提交：1）后退再提交 2）直接刷新
        //重定向，可以解决刷新一下，提交两次的问题
        out.print("<script>alert('新用户注册成功');window.location.replace('login.jsp');</script>");
        // request.getRequestDispatcher("subject.jsp").forward(request,response);
    }else{
        // out.print("增加失败，可能课程名重复了！");
        request.setAttribute("msg","增加失败，可能用户名重复了！");
        request.getRequestDispatcher("addAdmin.jsp").forward(request,response);
        //response.sendRedirect("subjectAdd.jsp");
    }
%>

</body>
</html>
